
import HomePage from './system/home/view/homePage.vue';
import TabPage from './system/home/view/tabPage.vue';
export default function getMemus(router,auths) {
    if({} === auths){
        return;
    }
    Object.keys(auths).forEach(function(items){
        router.options.routes.push({
            path: auths[items].path,
            component: HomePage,
            children: [],
            name: auths[items].parentRouteName,
            parentColumnName: auths[items].parentColumnName,
            id:auths[items].id
        });
        //导航栏路由
        if (auths[items].childs) {
            auths[items].childs.forEach(function (item) {
                router.options.routes.forEach(function (itemd) {
                    if (itemd.name !== "/" && itemd.name !== "login" && itemd.name !== "index") {
                        if (itemd.id === item.parentId) {
                            itemd.children.push({
                                path: item.path,
                                component: TabPage,
                                name: item.navRouteName,
                                navColumnName: item.navColumnName,
                                children: [],
                                id:item.id,
                                meta: { title: item.navColumnName, icon: item.icon,keepAlive: true },
                            });
                        }
                    }
                });
                //导航栏子路由
                if (item.childs) {
                    item.childs.forEach(function (dat) {
                        router.options.routes.forEach(function (it) {
                            if (it.name !== "/" && it.name !== "login" && it.name !== "index") {
                                it.children.forEach(function(d){
                                    if (d.id === dat.parentId) {
                                        d.children.push({
                                            path: dat.path,
                                            /*业务模块分开和主app.js分离*/
                                            component: resolve => {
                                                require(['src/lenovohit' + dat.childRoutePath], resolve);
                                            },
                                            name: dat.childRouteName,
                                            childColumnName: dat.childColumnName,
                                            meta: { title: dat.childColumnName, icon: dat.icon,keepAlive: true },
                                            id:dat.id
                                        });
                                    }
                                });
                            }
                        });
                    });
                }
            });
        }
    });
    router.addRoutes(router.options.routes);
};
